package com.stockz.equity.charting.display.indicator;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.stockz.equity.charting.painter.indicator.VsaIndicatorPainter;
import com.stockz.equity.charting.util.Constant.OVERLAY;
import com.stockz.equity.indicator.Indicator;
import com.stockz.equity.indicator.vsa.VsaBar;
import com.stockz.equity.indicator.vsa.VsaIndicator;
import com.stockz.equity.indicator.vsa.VsaIndicatorConfiguration;
import com.stockz.equity.model.Bar.BarValueType;

@Component
public class VsaIndicatorDisplay extends AbstractDisplayableIndicatorConfiguration {

	@Autowired private VsaIndicator vsaIndicator;
	
	private String fullName = "Volume Spread Analysis";
	private String shortName = "VSA";
	private List<VsaBar> vsaBarList;

	@Override
	public Indicator<VsaIndicatorConfiguration> getIndicator() {
		return vsaIndicator;
	}
	
	@Override
	public BarValueType getBarValueType() {
		return vsaIndicator.getBarValueType();
	}
	
	@Override
	public void setBarValueType(BarValueType barValueType) {
		vsaIndicator.setBarValueType(barValueType);
	}

	@Override
	public String getFullName() {
		return fullName;
	}

	@Override
	public String getShortName() {
		return shortName;
	}

	@Override
	public void refreshValues() {
		vsaBarList = vsaIndicator.convert(
				getStockChartView().getSelectedStockChart().getStockChartPanel()
				.getStockChartPanelState().getBarList());
	}

	@Override
	public String getDescription() {
		return getShortName();
	}

	@Override
	public Class<VsaIndicatorPainter> getPainterClass() {
		return VsaIndicatorPainter.class;
	}

	@Override
	public boolean isOverlappable() {
		return true;
	}

	@Override
	public OVERLAY getOverlay() {
		return OVERLAY.PRICE;
	}

	public List<VsaBar> getVsaBarList() {
		return vsaBarList;
	}
	
	@Override
	public Object getConfiguration() {
		return vsaIndicator.getIndicatorConfiguration();
	}
}

